Skip to content

[✨ Enhanced Sample] Implement Generative Expand (OutPainting) with Imagen 3.0#113

Open
madebymozart wants to merge 3 commits intomainfrom
madebymozart/outpainting-and-style-change
Open

[✨ Enhanced Sample] Implement Generative Expand (OutPainting) with Imagen 3.0#113
madebymozart wants to merge 3 commits intomainfrom
madebymozart/outpainting-and-style-change

Conversation

@madebymozart
Copy link
Contributor

Description

This pull request introduces the Generative Expand feature, a powerful implementation of outpainting that leverages the advanced capabilities of the Imagen 3.0 model. This new functionality empowers users to creatively extend the canvas of a generated image, seamlessly adding new content that is contextually consistent with the original.

The core objective is to allow users to transform a standard-sized generation into a larger, more comprehensive scene—whether it's widening a landscape, adding more context to a character portrait, or simply exploring what lies beyond the original frame.

Changes Introduced

  • 🖼️ New "Generative Expand" Functionality: Implemented the end-to-end logic for outpainting. The user can now select a generated image and expand its dimensions, with Imagen 3.0 intelligently filling in the new areas.
  • 🧠 Imagen 3.0 Integration: The backend service now calls the Imagen 3.0 model specifically for outpainting tasks, utilizing its state-of-the-art inpainting/outpainting capabilities to ensure high-quality, coherent results.
  • 🔒 Resolution Safeguards: To ensure system stability, manage computational costs, and maintain a high-quality user experience, specific constraints have been implemented. This prevents excessively large or "runaway" expansions that could lead to performance degradation or suboptimal outputs.

Technical Details & Implementation

The outpainting process works by sending the original image along with the desired new canvas dimensions to the model. The original image acts as a contextual prompt, and Imagen 3.0 generates the pixels for the new, empty regions.

A key implementation detail is the introduction of a resolution cap.

  • The final expanded image cannot exceed a maximum resolution of 4096x4096 pixels.
  • This restriction is validated on the backend before processing any request. If a user attempts to expand an image beyond this limit, the request will be gracefully rejected with a user-friendly error message. This prevents API abuse and ensures that generation times remain reasonable.

Note: This limit strikes a balance between offering creative freedom and maintaining the performance and reliability of the service.

How to Test 🧪

  1. Generate any initial image.
  2. In the image viewer/editor UI, locate and click the new "Expand" button.
  3. Choose a direction (e.g., left, right, top, bottom) and a size for the expansion.
  4. Confirm the action and wait for the generation to complete.
  5. Verify that the resulting image is a seamless and logical extension of the original.
  6. Test the limits:
    • Take a large image (e.g., 3000x3000).
    • Attempt to expand it in a way that would cause the total resolution to exceed 4096x4096.
    • Confirm that the UI displays an error message and the request is not sent.

Screenshots

| Before Expansion | After Expansion |

Screenshot 2025-10-06 at 1 40 33 PM * | * Screenshot 2025-10-06 at 1 40 39 PM * |

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants